/**
 * related to myListRowTemplate.ui
 * 
 * @Author : chenglm
 * @Timestamp : 2016-07-05
 */
var root=ui("$");
var helperOpen = require("helper/open");
var qqHttp = require("helper/http");
var userUtil = require("helper/user");
var urlUser = require("url/user");
var alayout_base = ui("alayout_base");
//设置数据绑定的映射关系
root.setMapping({
	"alayout_base.tag":"id",
	"do_Label_title.text":"typeStr",
	"do_Label_time.text":"strNewAt",
	"do_ImageView_img.source":"img",
	"todoOrderCount.tag":"todoOrderCount",
	"label_auditStatus.tag":"auditStatus",
});

root.on("dataRefreshed", function(){
	var imgList = ui("do_ImageView_img").source.split(";");
	if(imgList.length>0){
		ui("do_ImageView_img").source= img_domain+""+imgList[0];
	}
	if (ui("label_auditStatus").tag == 1) {
		ui("label_auditStatus").text = '待审核';
	} else if (ui("label_auditStatus").tag == 2) {
		ui("label_auditStatus").text = '审核通过';
	} else {
		ui("label_auditStatus").text = '审核不通过';
	}
	ui("todoOrderCount").text = "有" + ui("todoOrderCount").tag + "条预约等待服务";
});

alayout_base.on("touch", function(data){
	if (userUtil.hasIdentityAuth()==="2") { //未认证的话
		qqHttp.post(urlUser.url.base.detail, {}, function(data) {
			if (data.userBase.hasIdentityAuth == 2) {
				nf.toast("请先完成身份认证再操作");
				return;
			} else if (data.userBase.hasIdentityAuth == 1) { //已认证，则更新
				userUtil.hasIdentityAuth("1");
				helperOpen.open("source://view/homemaking/manage/edit.ui",{id:alayout_base.tag});
			}
		});
	} else {
		helperOpen.open("source://view/homemaking/manage/edit.ui",{id:alayout_base.tag});
	}
});